package com.qbgs.util;


import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.springframework.util.CollectionUtils;


/**
 * Key转换工具类
 * @author lyh
 * @version 2013-10-30
 * @see ConvertKeyUtil.java
 * @since
 */
public class ConvertKeyUtil
{

    /**
     * 把map对象的key全部转为小写形式
     * @param map
     * @return
     */
    public static Map<String, Object> keyToLower(Map<String, Object> map)
    {
        Map<String, Object> _map = new LinkedHashMap<String, Object>();
        if (CollectionUtils.isEmpty(map))
        {
            return _map;
        }
        for (Map.Entry<String, Object> entry : map.entrySet())
        {
            _map.put(entry.getKey().toLowerCase(), entry.getValue());
        }
        return _map;
    }

    /**
     * 把list map中map对象的key全部转为小写形式
     * @param listmap
     * @return
     */
    public static List<Map<String, Object>> listKeyToLower(List<Map<String, Object>> listMap)
    {
        List<Map<String, Object>> _listMap = new LinkedList<Map<String, Object>>();
        if (CollectionUtils.isEmpty(listMap))
        {
            return _listMap;
        }
        for (Map<String, Object> map : listMap)
        {
            _listMap.add(keyToLower(map));
        }
        return _listMap;
    }

    /**
     * 私有化
     */
    private ConvertKeyUtil()
    {

    }
}
